package com.wxtl.dao;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;

import com.wxtl.dao.base.HibernateBaseDao;
import com.wxtl.entity.DownLog;

/**
 * 
 * @author hc24
 * 
 */
@Repository
public class DownLogDAO extends HibernateBaseDao {
	private static final Log log = LogFactory.getLog(DownLogDAO.class);
	
	/**
	 * 根据客户和升级补丁查询日志
	 * @param custsn
	 * @param upCode
	 * @return
	 */
	public DownLog queryByLog(String custsn, int upgradeId) {
		List<DownLog> list = getSession().createQuery(
				"from DownLog dl where dl.custsn=? and dl.upgradeId=?  order by dl.downTime desc")
				.setParameter(0, custsn).setParameter(1, upgradeId).list();
		if(list.size()>0)
			return list.get(0);
		return null;
		
	}
	
	
	/**
	 * 根据升级补丁编码查询日志
	 * @param upCode
	 * @return
	 */
	public List<DownLog> queryLogByCode(String upCode) {
		List<DownLog> list = getSession().createQuery(
				"from DownLog dl where dl.upCode=?").setParameter(0, upCode).list();
		if(list.size()>0)
			return list;
		return null;
		
	}
}